package LC17;

import java.util.HashMap;
import java.util.Map;

/**
 * 1657. 确定两个字符串是否接近
 *
 * @author zhangsan
 */
public class LC1657 {

    public static boolean closeStrings1(String word1, String word2) {
        Map<String, Integer> map1 = getDistinctMap(word1);
        Map<String, Integer> map2 = getDistinctMap(word2);
        if (map1.size() != map2.size()) {
            return false;
        }
        if (!map1.keySet().containsAll(map2.keySet())) {
            return false;
        }

        Map<String, Integer> map11 = getDistinctMap1(map1.values().stream().toArray());
        Map<String, Integer> map22 = getDistinctMap1(map2.values().stream().toArray());
        if (!map11.entrySet().containsAll(map22.entrySet())) {
            return false;
        }
        return true;
    }

    public static Map<String, Integer> getDistinctMap(String word) {
        char[] charArray = word.toCharArray();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < charArray.length; i++) {
            String key = String.valueOf(charArray[i]);
            map.put(key, map.getOrDefault(key, 0) + 1);
        }
        return map;
    }

    public static Map<String, Integer> getDistinctMap1(Object[] arr) {
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < arr.length; i++) {
            String key = String.valueOf(arr[i]);
            map.put(key, map.getOrDefault(key, 0) + 1);
        }
        return map;
    }

    public static void main(String[] args) {
        System.out.println(closeStrings("cabbba", "cabbba"));
    }

    public static boolean closeStrings(String word1, String word2) {

        return true;
    }
}
